package Interfaces;

public class SortingExample {
    public static void main(String[] args) {
        int[] numbers = { 64, 25, 12, 22, 11 };

        // 使用 BubbleSorter
        Sorter bubbleSorter = new BubbleSorter();
        bubbleSorter.sort(numbers);
        printArray(numbers, "Bubble Sort");

        // 重新初始化数组以便再次排序
        numbers = new int[] { 64, 25, 12, 22, 11 };

        // 使用 SelectionSorter
        Sorter selectionSorter = new SelectionSorter();
        selectionSorter.sort(numbers);
        printArray(numbers, "Selection Sort");
    }

    // 打印数组内容
    private static void printArray(int[] array, String sortType) {
        System.out.println(sortType + ": ");
        for (int value : array) {
            System.out.print(value + " ");
        }
        System.out.println();
    }
}
